from time import time

class module:
	def __init__(self, parent):
		self.parent = parent

		self.events = ["onCTCP"]
		self.metadata = {
			"name":"CTCP",
			"description":"CTCP handling",
			"author":"Samuel Gordalina",
			"email":"samuel.gordalina@gmail.com",
			"version":"0.1",
			"required_version":(0,1)
		}

	def onCTCP(self, mask, ctcp, msg=None):
		nick = src.split('!')[0][0:]
		
		if ctcp == "VERSION":
			self.parent.irc.ctcpReply(nick, "VERSION", "fanhoso 0.1-alpha")
		elif ctcp == "PING":
			self.parent.irc.ctcpReply(nick, "PING", "%ld" % time())
		elif ctcp == "TIME":
			self.parent.irc.ctcpReply(nick, "TIME", strftime("%a %b %d %H:%M:%S %Y"))
		else:
			self.parent.irc.ctcpReply(nick, ctcp, "Don't " + ctcp.lower() + " me, bitch!")
